package com.imut.hcdp.controller;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.imut.hcdp.domain.HcdpAddTrainRouteParam;
import com.imut.hcdp.domain.HcdpTrain;
import com.imut.hcdp.domain.RouteResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.imut.hcdp.common.Rst;

import com.imut.hcdp.domain.HcdpTrainRoute;
import com.imut.hcdp.service.IHcdpTrainRouteService;



@RestController
@RequestMapping("/system/route")
public class HcdpTrainRouteController
{
    @Autowired
    private IHcdpTrainRouteService hcdpTrainRouteService;


    /**
     * 查询火车票信息
     * @param hcdpTrainRoute
     * @param request sCity eCity sTime
     * @return
     */
    @GetMapping("/searchList")
    public Rst list(HcdpTrainRoute hcdpTrainRoute, HttpServletRequest request) throws ParseException {
        List<RouteResult> list = hcdpTrainRouteService.selectHcdpTrainRouteList(hcdpTrainRoute);
        return Rst.success(list);
    }



    @GetMapping("/list")
    public Rst listAdmin(HcdpTrainRoute hcdpTrainRoute) throws ParseException {
        return Rst.success(hcdpTrainRouteService.list(hcdpTrainRoute));
    }





    @GetMapping(value = "/{id}")
    public Rst getInfo(@PathVariable("id") Long id)
    {
        return Rst.success(hcdpTrainRouteService.selectHcdpTrainRouteById(id));
    }


    /**
     * 新增行程信息
     * @param hcdpTrainRoute
     * @return
     */
    @PostMapping
    public Rst add(@RequestBody HcdpAddTrainRouteParam hcdpTrainRoute)
    {
        return Rst.success(hcdpTrainRouteService.insertHcdpTrainRoute(hcdpTrainRoute));
    }




    @PutMapping
    public Rst edit(@RequestBody HcdpTrainRoute hcdpTrainRoute)
    {
        return Rst.success(hcdpTrainRouteService.updateHcdpTrainRoute(hcdpTrainRoute));
    }




	@DeleteMapping("/{ids}")
    public Rst remove(@PathVariable Long[] ids)
    {
        return Rst.success(hcdpTrainRouteService.deleteHcdpTrainRouteByIds(ids));
    }

    @DeleteMapping("/del/{id}")
    public Rst removeById(@PathVariable Long id)
    {
        return Rst.success(hcdpTrainRouteService.deleteHcdpTrainRouteById(id));
    }
}
